#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<map>

using namespace std;

int winningPlayerCount(int n, vector<vector<int>>& pick) {
    map<pair<int, int>, int> m;
    for (auto& p : pick)
        m[{p[0], p[1]}]++;

    int res = 0;
    for (auto& [k, v] : m)
        if (v >= k.first + 1)
            res |= 1 << k.first;
    return __builtin_popcount(res);
}